﻿<?xml version="1.0" encoding="utf-8"?><Articles><Article><ArticlesID>573</ArticlesID><Title>C&amp;#225;ch chụp h&amp;#236;nh 1 form trong .NET</Title><Body>&amp;lt;p&amp;gt;_C&amp;amp;aacute;ch chụp h&amp;amp;igrave;nh 1 form rồi đưa ra file dạng { enum ImageFormat } . ở đ&amp;amp;acirc;y v&amp;amp;iacute; dụ file *.jpeg&amp;lt;br /&amp;gt;
&amp;lt;br /&amp;gt;
_Lấy thư viện :&amp;lt;br /&amp;gt;
&amp;lt;br /&amp;gt;
_Code:&amp;lt;/p&amp;gt;
&amp;lt;pre title=&amp;quot;code&amp;quot; class=&amp;quot;brush: csharp;&amp;quot;&amp;gt;
[System.RuntiInteropServices.DllImportAttribute(&amp;amp;quot;gdi32.dll&amp;amp;quot;)]
// Lấy API ra :D
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);
// ch&amp;amp;eacute;p nguy&amp;amp;ecirc;n xi định nghĩa cho dễ hiểu
// Lấy đối tượng
IntPtr dc1 = aGraphicsObject.GetHdc();

// Tạo button rồi xử l&amp;amp;yacute; chụp h&amp;amp;igrave;nh form
private void Button_Click(object sender, System.EventArgs e)
{
Graphics g1 = this.CreateGraphics();
Image MyImage = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height, g1);
Graphics g2 = Graphics.FromImage(MyImage);
IntPtr dc1 = g1.GetHdc();
IntPtr dc2 = g2.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);
g1.ReleaseHdc(dc1);
g2.ReleaseHdc(dc2);
MyImage.Save(@&amp;amp;quot;c:\Captured.jpg&amp;amp;quot;, ImageFormat.Jpeg);
}&amp;lt;/pre&amp;gt;
&amp;lt;p&amp;gt;ST&amp;lt;/p&amp;gt;</Body><CommentEnabled>True</CommentEnabled><ViewCount>0</ViewCount><ReleaseDate>11/1/2009 12:10:12 AM</ReleaseDate><TotalComment>0</TotalComment><IsMedia>False</IsMedia><IsPicture>False</IsPicture><IsVote>True</IsVote><ArticlePassword /><PostVisible>0</PostVisible><ArticlePath>/2009/11/1/Cach-chup-hinh-1-form-trong--NET-23D</ArticlePath><Approved>True</Approved><ImagePath /><CategoryId>43</CategoryId><ArrayCatID>43|25</ArrayCatID></Article></Articles>